var WxParse = require('../../wxParse/wxParse.js');
const app = getApp();
const {
  noticelist
} = require('../../config.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    title:'',
    content: '',
    dateAdd:''
  },

  /**
    * WxParse.wxParse(bindName, type, data, target, imagePadding)
    * 1.bindName绑定的数据名(必填)
    * 2.type可以为html或者md(必填)
    * 3.data为传入的具体数据(必填)
    * 4.target为Page对象, 一般为this(必填)
    * 5.imagePadding为当图片自适应是左右的单一padding(默认为0, 可选)
   */
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let { id } = options;

    app.appRequest({
      url: noticelist,
      success: (res) => {
        let noticelist = res.data.pageBean.result;
        noticelist.forEach(item => {
          if (item.id == id){
            let that = this;
            WxParse.wxParse('wxcontent', 'html', item.content, that, 5);
            this.setData({
              title: item.title,
              dateAdd: item.dateAdd
            }) 
          }
        })
        
      }
    })
  },

})